<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            margin: 200px;
        }
        
        span {
            display: inline-block;
            width: 40px;
            height: 40px;
            background-color: #333;
            font-size: 20px;
            color: #fff;
            text-align: center;
            line-height: 40px;
        }
    </style>
</head>

<body>
    <div>
        <span class="hour"></span>
        <span class="minute"></span>
        <span class="second"></span>
    </div>
    <!-- d=parseInt(总秒数/60/60/24)---计算天数 -->
    <!-- h=parseInt(总秒数/60/60%24)---计算小时 -->
    <!-- m=parseInt(总秒数/60%60)---计算分数 -->
    <!-- s=parseInt(总秒数%60)---计算分数 -->

    <script>
        var hour = document.querySelector('.hour')
        var minute = document.querySelector('.minute')
        var second = document.querySelector('.second')
        var inputTime = +new Date('2020-9-26 16:59:00')
        countDown("2020-9-26 19:59:00")
        setInterval('countDown("2020-9-26 19:59:00")', 1000)

        function countDown(timer) {
            var nowTime = +new Date();
            var inputTime = +new Date(timer)
            var times = (inputTime - nowTime) / 1000
            var h = parseInt(times / 60 / 60 % 24)
            h = h < 10 ? '0' + h : h
            hour.innerHTML = h;
            var m = parseInt(times / 60 % 60)
            m = m < 10 ? '0' + m : m
            minute.innerHTML = m
            var s = parseInt(times % 60)
            s = s < 10 ? '0' + s : s
            second.innerHTML = s
        }
    </script>

</body>

</html>